package marvin.webapp.audio.action;

import java.io.IOException;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import marvin.webapp.common.util.WebPageURLs;
import org.primefaces.event.TabChangeEvent;

@ManagedBean
@SessionScoped
public class MobileAction extends AbstractAudioWebAction {

	private int activeIndex = 0;

	@PostConstruct
	public void load() {
		getLoad();
	}

	public void goToClients() {
		try {
			FacesContext.getCurrentInstance().getExternalContext()
					.redirect(WebPageURLs.AUDIO_MOBILE_PAGE);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void goToAudio() {
		try {
			FacesContext.getCurrentInstance().getExternalContext()
					.redirect(WebPageURLs.AUDIO_AUDIO_PAGE);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void goToHome() {
		try {
			FacesContext.getCurrentInstance().getExternalContext()
					.redirect("/marvin");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void onTabChange(TabChangeEvent event) {
		System.out.println(event.getTab().getId());
	}

	public int getActiveIndex() {
		return activeIndex;
	}

	public void setActiveIndex(int activeIndex) {
		this.activeIndex = activeIndex;
	}
}
